807A - Is it rated - CodeForces Solution


implementation sortings *900

Please click on ads to support us..

Python Code:

class Solution():

    def is_it_rated(participants):
        ratings = []
        for participant in range(participants):
            rating_before, rating_after = map(int, input().split())
            if rating_after != rating_before:
                return "rated"
            else:
                ratings.append(rating_after)
        if ratings != sorted(ratings, reverse= True):
            return "unrated"
        else:
            return "maybe"
        


if __name__ == '__main__':
    participants = int(input())
    print(Solution.is_it_rated(participants))

C++ Code:

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
#define pf push_front
//#define endl '\n'
#define MAXN 32000
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("O3,Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll >, rb_tree_tag,
        tree_order_statistics_node_update>
        newset;
ll i,j,a,k,b,c,n,t=1,m,p,q,d,e,f,y,g,z,h,r,l,x,u,o;
ld aa,bb,ee,dd,ff,kk,gg,cc;
vector<ll> v[100006],s,vv;
vector< pair<pair<ll,ll>,ll> > ss,pp,hh;
map<ll,ll > ta,pa,sa,ma;
map< pair<ll,ll>, ll >se,me;
priority_queue<ll,vector<ll>,greater<ll> > aq,tq,pq,nq,mq,xq;
string st,et,ft,pt,ct;
deque<pair<ll,ll> > de,ne;
set<ll > li,si;

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

int main()
{
    fast;

    //cin>>t;

    while(t--)
    {
        cin>>n;
        f = 0;
        for(i=0; i<n; i++)
        {
            cin>>a>>b;
            if(a!=b)f=1;
            ss.pb({{a,b},i});
        }

        for(i=0; i+1<n; i++)
        {
            if(ss[i].first.second<ss[i+1].first.second && f==0){f=2;break;}
        }
        if(f==1)cout<<"rated"<<endl;
        else if(f==2)cout<<"unrated"<<endl;
        else cout<<"maybe"<<endl;
    }

}


 	 		  						 		 	 	 	   	   		


Comments

Submit
0 Comments
More Questions

Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches
HRDSEQ Hard Sequence
DRCHEF Doctor Chef